package com.hooya.fa.eu.biz.dao.mapper.stk;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hooya.fa.eu.biz.dao.entity.TempXsjl;
import com.hooya.fa.eu.biz.dao.entity.dto.B2cDataDTO;
import com.hooya.fa.eu.biz.dao.entity.dto.TempKcjlDailyHyDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @Description 1
 * @Author : Zongz
 * @Copyright Copyright (c) 豪雅集团
 * @Create 2024/3/18
 * @Version 1.0.0
 */
@Mapper
@DS("fa_eu")
public interface TempXsjlMapper extends BaseMapper<TempXsjl> {

    void insertBatchSomeColumn(List<TempXsjl> list);

	@DS("fa_eu_daily")
	void insertBatchSomeColumnDaily(List<TempXsjl> list);

    List<TempXsjl> getListByDate(@Param("start") String startDate, @Param("end") String endDate);

    /**
     * 根据时间获取销售和买卖的sheet number列表
     *
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @return list
     */
    List<String> getXsMmSheetNumberListByDate(@Param("startDate") String startDate, @Param("endDate") String endDate);

    @Select("SELECT sheetnumber FROM `temp_xsjl` where orderdate < '2025-09-02' group by sheetnumber")
    Set<String> selectDistinctSheetNumber();

	@DS("fa_eu")
	@Select("SELECT sheetnumber FROM `temp_xsjl` where orderdate < #{startDate} group by sheetnumber ")
	Set<String> selectDistinctSheetNumberDaily(String startDate);

	@Select("SELECT sum(sl) as sl, cpbh, orderdate as date, chck as place, belongs FROM fa_eu.temp_xsjl WHERE orderdate >= #{startDate} AND orderdate < #{endDate} AND belongs LIKE #{prefix1} OR belongs LIKE #{prefix2} GROUP BY cpbh,orderdate,chck,belongs")
	List<TempKcjlDailyHyDTO> getXsjlData(@Param("startDate") String startDate, @Param("endDate")String endDate, @Param("prefix1")String prefix1, @Param("prefix2")String prefix2);

	List<B2cDataDTO> getXsjlB2CData(@Param("start") String start, @Param("end")String end);
}
